<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>组合对话框</title>
        <#include "/pubHeadStyle.html">
        <script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
    </head>
    <body>
<div class="ccpui-tablesize" style="padding:10px;">
    <table id="comdinDialog" lay-filter="comdinDialog"></table>
</div>
<div class="layui-btn-container" style="position: absolute;bottom: 0;left:40%">
    <a class="layui-btn" id="save">保存</a>
    <a class="layui-btn layui-btn-danger" id="cancel">取消</a>
</div>
<script type="text/html" id="formDialogToolsBar">
    <div class="layui-btn-container">
        <a class="layui-btn layui-btn-sm" lay-event="query">
            <i class="layui-icon layui-icon-search"></i>
            <span>查询</span>
        </a>
    </div>
    <form class="layui-form" action="" style="margin-top:10px" lay-filter="formDialog_query">
        <div class="table-top-filter">
            <div class="table-filter-alone">
                <label class="layui-form-label" style="width: 132px;">名称 </label>
                <input type="text" name="Q_name_SL" id="name" class="layui-input filter-value" placeholder="名称"
                       autocomplete="off"/>
            </div>
            <div class="table-filter-alone">
                <label class="layui-form-label">别名 </label>
                <input type="text" name="Q_alias_SL" id="alias" class="layui-input filter-value" placeholder="别名"
                       autocomplete="off"/>
            </div>
        </div>
    </form>
</script>
<script>
    var dialogId = '${dialogId}';
    var selectDialog;
        layui.config({
            base: serverPath.formPath + staticPath.formPath //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index', 'table', 'layer', 'jquery', 'form', 'tree', 'commons', 'common', 'totalFilter', 'setter'], function () {
        var table = layui.table, layer = layui.layer, setter = layui.setter, commons = layui.commons,form=layui.form,
            common = layui.common, totalFilter = layui.totalFilter;
        var dialogType = '${dialogType}';
        common.tableSort("comdinDialog");
        $("#cancel").on('click',function(){
            layui.dialogSelect = selectDialog;
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
        $("#save").on('click',function(){
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
        //渲染表格
        table.render({
            elem: '#comdinDialog'
            , cellMinWidth: 80
            , title: '组合对话框弹窗表'
            , defaultToolbar: []
            , height: 'full-70'
            , url: serverPath.formPath + setter.formLinkPath + 'formDialog/list'
            , toolbar: '#formDialogToolsBar'
            , page: true
            , where:{style:dialogType}
            , autoSort: false
            , cols: [[
                {type: 'radio', fixed: 'left'}
                , {field: 'dialogId', title: 'ID', hide: true}
                , {field: 'name', title: '名称', sort: true, align: 'center'}
                , {field: 'alias', title: '别名', sort: true, align: 'center'}
            ]],
            parseData: function (res) {
                var _data = res.data;
                if (_data.length > 0 ) {
                    for (var i = 0; i < _data.length; i++) {
                        var _d = _data[i];
                        if(_d.id == dialogId){
                            _d.LAY_CHECKED = true;
                            selectDialog = _d;
                        }
                    }
                }
            }
        });
        totalFilter.init('comdinDialog');
        table.on('toolbar(comdinDialog)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data; //获取选中行数据
            switch (obj.event) {
                case 'query':
                    common.tableConditionRender("comdinDialog", "formDialog_query", {where: {}}, false);
                    break;
            }
        });
        //单选框选择事件
        table.on('radio(comdinDialog)', function (obj) {
            var data = obj.data;
            layui.dialogSelect = data;
        });

    });
</script>
    </body>
</html>